#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2025/2/5 16:20
# @Author  : Fancy
# @FileName: logger.py
# @Software: PyCharm
# @runstate    ：
# utils/logger.py
import logging
from pathlib import Path


def setup_logger (name: str, log_file: str = 'compare.log'):
    logger = logging.getLogger (name)
    logger.setLevel (logging.DEBUG)

    # 文件日志
    file_handler = logging.FileHandler (log_file)
    file_handler.setFormatter (
        logging.Formatter ('%(asctime)s - %(levelname)s - %(message)s')
    )

    # 控制台日志
    console_handler = logging.StreamHandler ()
    console_handler.setFormatter (
        logging.Formatter ('%(levelname)s: %(message)s')
    )

    logger.addHandler (file_handler)
    logger.addHandler (console_handler)
    return logger